load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "disk",
    srcs = [
        "linux_parse.go",
        "monitor.go",
        "monitor_tracer.go",
        "platform_darwin.go",
        "platform_default.go",
        "platform_linux.go",
        "stats.go",
        "stats_collector.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/storage/disk",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/util/envutil",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_pebble//vfs",
    ] + select({
        "@io_bazel_rules_go//go/platform:android": [
            "//pkg/util/sysutil",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:darwin": [
            "//pkg/util/sysutil",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:ios": [
            "//pkg/util/sysutil",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:linux": [
            "//pkg/util/sysutil",
            "@org_golang_x_sys//unix",
        ],
        "//conditions:default": [],
    }),
)

go_test(
    name = "disk_test",
    srcs = [
        "linux_parse_test.go",
        "monitor_test.go",
        "monitor_tracer_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":disk"],
    deps = [
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "@com_github_cockroachdb_datadriven//:datadriven",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_pebble//vfs",
        "@com_github_stretchr_testify//require",
    ],
)
